package com.zlyx.easy.web.web.controller;

import com.alibaba.fastjson.JSON;
import com.zlyx.easy.core.annotations.Desc;
import com.zlyx.easy.core.cache.CacheUtils;
import com.zlyx.easy.core.utils.ThreadManager;
import com.zlyx.easy.log.loggers.Logger;
import com.zlyx.easy.log.loggers.LoggerFactory;
import com.zlyx.easy.swagger.annotations.SpringMapping;

/**
 * 控制器基础方法定义层
 * 
 * @Auth 赵光
 * @Describle
 * @Date 2019年1月4日 下午8:59:49
 */
public abstract class BaseController {

	public Logger logger = LoggerFactory.getLogger(this.getClass());

	@SpringMapping(notes = "查看缓存", todo = { "查看缓存" }, value = { "/queryCache" })
	public Object queryCache() {
		return CacheUtils.getCache();
	}

	@SpringMapping(notes = "清除缓存", todo = { "清除缓存" }, value = { "/clearCache" })
	public void clearCache() {
		CacheUtils.clear();
	}

	@SpringMapping(notes = "查看线程池状态", todo = { "查看线程池状态" }, value = { "/queryThreads" })
	public Object queryThreads() {
		return ThreadManager.getThreads();
	}

	@Desc("结果转json串")
	protected String doSuccess(Object e) {
		return JSON.toJSONString(e);
	}
}
